<html>
	<head>

		<script type="text/javascript">

		function checkBrackets(bracketString)
		{
		var output = document.getElementById('output');
		var i;      
		var counter = 0;
		for(i = 0;i<bracketString.length;i++)
		{
			if (bracketString[i]=='(') {counter += 1;};
			if (bracketString[i]==')') {counter -= 1;};
		}
		if (counter === 0) 
			{
				var p = document.createElement("p");
				var text = document.createTextNode(bracketString+" "+"Everything matches!");
				p.appendChild(text);
				output.appendChild(p);
			}
		else
		{
			var p = document.createElement("p");
				var text = document.createTextNode(bracketString+" "+"Brackets don't match!");
				p.appendChild(text);
				output.appendChild(p);
		}
		}

		function onClick()
		{
		var example1 = "((a+b)/5-d)";
		var example2 = ")(a+b))";
		var example3 = "((a+b))";
		var example4 = "(((a+b))";
		var example5 = "(((a+b)))((((())))";
		var example6 = "(((a+b)))((((()))))";
		checkBrackets(example1);
		checkBrackets(example2);
		checkBrackets(example3);
		checkBrackets(example4);
		checkBrackets(example5);
		checkBrackets(example6);        
		};
		</script>
		<title></title>
	</head>
	<body>
		<p>
			Reverse the word "example"
		</p>
		<pre>
		example1 = "((a+b)/5-d)";
		example2 = ")(a+b))";
		example3 = "((a+b))";
		example4 = "(((a+b))";
		example5 = "(((a+b)))((((())))";
		example6 = "(((a+b)))((((()))))";
</pre>
<button onclick="onClick()" id="buttonOne">Check brackets</button>
		<p>
			Output
		</p>
		<div id="output"></div>
	</body>
</html>